package ve.ejb.entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import ve.ejb.metadata.Settings;

/**
 *
 * @author memozac
 */
@Entity
public class ActionPlan implements Serializable {
    private static final long serialVersionUID = 1L;

    public enum Status{UNINITIALIZED,DELAYED,ON_TIME,TERMINATED};

    @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long idActionPlan;

    @ManyToOne private Person responsible;

    @ManyToOne private Person author;

    @ManyToOne private ScoreCard scoreCard;

    @OneToOne private Agreement agreement;

    @OneToOne private Settings settings;

    @OneToMany private Collection<Activity> activities;

    @ManyToMany(targetEntity=ScoreCard.class) @JoinTable(name="ActionPlanScoreCard", joinColumns=@JoinColumn(name="idActionPlan"),
    inverseJoinColumns=@JoinColumn(name="idScoreCard")) private Collection<ScoreCard> scoreCards;

    @Column(columnDefinition="text") private String name;

    @Column(columnDefinition="text") private String description;

    @Temporal(value = TemporalType.TIMESTAMP) private Date registerDate;

    @Enumerated private Status status;

    public Settings getSettings() {
        return settings;
    }

    public void setSettings(Settings settings) {
        this.settings = settings;
    }

    public Status getStatus() {
        return status;
    }

    public void setStatus(Status status) {
        this.status = status;
    }

    public Date getRegisterDate() {
        return registerDate;
    }

    public void setRegisterDate(Date registerDate) {
        this.registerDate = registerDate;
    }

    public Agreement getAgreement() {
        return agreement;
    }

    public void setAgreement(Agreement agreement) {
        this.agreement = agreement;
    }

    public ScoreCard getScoreCard() {
        return scoreCard;
    }

    public void setScoreCard(ScoreCard scoreCard) {
        this.scoreCard = scoreCard;
    }

    public Collection<Activity> getActivities() {
        return activities;
    }

    public void setActivities(Collection<Activity> activities) {
        this.activities = activities;
    }

    public Person getAuthor() {
        return author;
    }

    public void setAuthor(Person author) {
        this.author = author;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Long getIdActionPlan() {
        return idActionPlan;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Person getResponsible() {
        return responsible;
    }

    public void setResponsible(Person responsible) {
        this.responsible = responsible;
    }

    public Collection<ScoreCard> getScoreCards() {
        return scoreCards;
    }

    public void setScoreCards(Collection<ScoreCard> scoreCards) {
        this.scoreCards = scoreCards;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idActionPlan != null ? idActionPlan.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof ActionPlan)) {
            return false;
        }
        ActionPlan other = (ActionPlan) object;
        if ((this.idActionPlan == null && other.idActionPlan != null) || (this.idActionPlan != null && !this.idActionPlan.equals(other.idActionPlan))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ve.ejb.entity.ActionPlan[id=" + idActionPlan + "]";
    }

}//ends of class
